import { QXEvent } from "qx-util";
import { IParam, ChartActionType, IChartAbility, IChartControllerParams, IChartStore, ChartController, ICtrlEvent, IChartController, IChartModel } from "@/core";
import { useChartAction, useChartBasic, useChartControllerParams, useChartProps } from "@/hooks/widget/use-chart";
import { ChartControlVO } from './area-chart-vo';
import { model } from "./area-chart-model";
import ChartService from "@/core/modules/ctrl-service/chart-service";
// 基于template/src/widgets/{{appEntities}}/{{ctrls@CHART}}-chart/{{spinalCase ctrl.codeName}}-chart-hook.ts.hbs生成
/**
 * 获取输入参数
 *
 * @export
 * @return {*}
 */
export function useProps() {
	return {
		...useChartProps(),
	};
}

/**
 * 获取基础数据
 *
 * @export
 * @param {*} props
 * @return {*}
 */
export function useBasic(props: any) {
	return {
		...useChartBasic(model, props),
	};
}

/**
 * 获取行为
 *
 * @export
 */
export function useAction(controller: any) {
	return {
		...useChartAction(controller),
	};
}

/**
 * 获取控制器
 *
 * @export
 * @param {IParam} props
 * @param {QXEvent<ICtrlEvent<ChartActionType, IChartAbility>>} evt
 * @return {*}
 */
export function useController(
	props: IParam,
	evt: QXEvent<ICtrlEvent<ChartActionType, IChartAbility>>,
    otherParams: IParam = {},
): IChartController<IChartStore, IChartAbility> {
	const params: IChartControllerParams<ChartActionType, IChartAbility> =
		useChartControllerParams<IChartStore, IChartModel>(model, props, evt, otherParams);
    const ctrlService = new ChartService<ChartControlVO>(ChartControlVO, model.entityCodeName, { model });
  	Object.assign(params, { ctrlService });
  	return new ChartController(params);
}